// pages/yoshop/user/fly.js
let _this
let wxApi = require('../../utils/wxApi.js')
let wxRequest = require('../../utils/wxRequest.js')
let Fly = require('../../utils/wx.js')
let fly = new Fly()
let App = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    bmobObjectId: '',
    joinCoourses: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    _this = this

    fly.interceptors.request.use((config, promise)=>{
      config.headers['content-type'] = 'application/json'
      config.headers['X-Bmob-Application-Id'] = App.application_id
      config.headers['X-Bmob-REST-API-Key'] = App.rest_api_key
    })
    fly.config.baseURL = App.api_root
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

    _this.getResource().then(res=>{
      console.log(res)
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  getResource: function () {
    let _url = App.api_root + 'classes/Resource'
    return wxRequest.get(_url,{})
  },

  getArticle: function () {
    let _url = App.api_root + 'classes/Article'
    return fly.get(_url)
  }
})